﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class CheckUserName : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string userName = Request["username"].ToString();
        string userPwd = Request["userpwd"].ToString();
        string ConnStr = "server=.\\sqlexpress; database=Student; User ID=sa;Password=sa";
        using (SqlConnection conn=new SqlConnection(ConnStr))
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.Connection = conn;
            cmd.CommandText = "Select * from studentinfo where UserName='" + userName + "'and UserPwd='" + userPwd + "'";
            SqlDataReader dr = cmd.ExecuteReader();
            if(dr.Read())
            {
                dr.Close();
                //Response.Redirect("Default.aspx");
                Response.Write("登陆成功!");
            }
            else
            {
                Response.Write("用户名或密码错误");
            }
        }
    }
}